package zhihuilan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import zhihuilan.entity.MyOrder;
import zhihuilan.entity.MyOrderDetail;
import zhihuilan.mapper.MyOrderDetailMapper;
import zhihuilan.service.MyOrderDetailService;
import java.util.List;

/**
 * 部门管理 服务实现
 *
 * @author ruoyi
 */
@Service
public class MyOrderDetailServiceImpl extends ServiceImpl<MyOrderDetailMapper, MyOrderDetail> implements MyOrderDetailService {


    @Override
    public Boolean deleteByOrderNoAndStaffId(Integer staffId, List<String> orderNoList) {
        if (ObjectUtils.isEmpty(staffId) || ObjectUtils.isEmpty(orderNoList)) {
            return false;
        }
        QueryWrapper<MyOrderDetail> queryWrapper = new QueryWrapper<>();
        if (!ObjectUtils.isEmpty(staffId)) {
            queryWrapper.eq("staffid", staffId);
        }
        if (!ObjectUtils.isEmpty(orderNoList)) {
            queryWrapper.in("orderno", orderNoList);
        }
        return this.baseMapper.delete(queryWrapper) > 0 ? true : false;
    }

    @Override
    public List<MyOrderDetail> selectByOrderNo(String orderNo){
        QueryWrapper<MyOrderDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("orderno", orderNo);
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean saveEntitys(List<MyOrderDetail> myOrderDetails){

        return this.saveBatch(myOrderDetails);
    }
}
